package com.scedu.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
class OrderController {
    @Autowired
    private RestTemplate restTemplate;
    @Value("${server.port}")
    private String port;
    public  static  final  String PAYMENT_URL="http://naco-payment-provider";
    @RequestMapping(value = "/consumer/{id}", method = RequestMethod.GET)
    public String echo(@PathVariable String id) {
        String forObject = restTemplate.getForObject(PAYMENT_URL+"/payment/" + id, String.class);
        return "Orderport:"+port+" 返回的结果" + forObject;
    }
}
